Package edu.claflin.finder.io.graph
Class SimpleGraphIO
- java.lang.Object
-
- edu.claflin.finder.io.graph.SimpleGraphIO
-
- All Implemented Interfaces:
GraphReader,GraphWriter
public final class SimpleGraphIO extends java.lang.Object implements GraphReader, GraphWriter
A class for reading and writing graphs.- Version:
- 3.1.2 February 2, 2016
- Author:
- Charles Allen Schultz II
-
-
Constructor Summary
Constructors Constructor Description SimpleGraphIO()Empty Constructor for instantiating the class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GraphparseGraph(java.io.File source, boolean undirected)Reads a graph from memory.private static booleantestFile(java.io.File file)Tests to see if a File is a valid graph file.private java.lang.DoubleverifyRelationship(java.lang.Object edgeData)rapin001 @ 3/2020 Function to verify the edge data is a DoublevoidwriteGraph(Graph toWrite)Writes graphs to memory.
-
-
-
Method Detail
-
parseGraph
public Graph parseGraph(java.io.File source, boolean undirected)
Reads a graph from memory. Reads simple tab delimited graphs. A graph file consists of an edge on each line with a tab delimiting the two nodes joined by the edge and followed by a floating point value representing the edge weight.- Specified by:
parseGraphin interfaceGraphReader- Parameters:
source- the File object representing the graph.undirected- a boolean indicating if the graph should be interpreted as undirected.- Returns:
- the Graph object parsed from the file.
-
writeGraph
public void writeGraph(Graph toWrite)
Writes graphs to memory. Writes simple tab delimited graphs. Outputs to the disk a graph. Each line of the outputted graph represents an edge. The two nodes joined by the edge are delimited by a tab.- Specified by:
writeGraphin interfaceGraphWriter- Parameters:
toWrite- theGraphobject to write to a file.
-
testFile
private static boolean testFile(java.io.File file)
Tests to see if a File is a valid graph file. Currently only tests by checking to ensure the provided file is not a directory.- Parameters:
file- the File to test.- Returns:
- the boolean value representing if the file is valid.
-
verifyRelationship
private java.lang.Double verifyRelationship(java.lang.Object edgeData)
rapin001 @ 3/2020 Function to verify the edge data is a Double- Parameters:
edgeData- object that you want to verify the class of to be Double- Returns:
- Double edge weight or 0 if edge data is not a Double
-
-